package com.tanxi521.springboot.service.impl;

import com.tanxi521.springboot.bean.PlayerInfoCard;
import com.tanxi521.springboot.mapper.AfkRewardsMapper;
import com.tanxi521.springboot.mapper.OaUserMapper;
import com.tanxi521.springboot.mapper.PlayerAccountMapper;
import com.tanxi521.springboot.mapper.PlayerInfoCardMapper;
import com.tanxi521.springboot.pojo.*;
import com.tanxi521.springboot.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: i-xiaotian
 * @Date: 2022/3/26 0:50
 * @EMAIL: 1254806967@qq.com
 */
@Service
public class UserServiceImpl implements UserService {

    @Resource
    PlayerAccountMapper playerAccountMapper;

    @Resource
    OaUserMapper oaUserMapper;

    @Resource
    AfkRewardsMapper afkRewardsMapper;

    @Resource
    PlayerInfoCardMapper playerInfoCardMapper;

    @Override
    public PlayerAccount queryPlayerAccount(PlayerAccount playerAccount) {
        return playerAccountMapper.selectByPlayerRealName(playerAccount);
    }

    @Override
    public String queryPlayerUuid(String userName) {
        return afkRewardsMapper.selectByUserName(userName);
    }

    @Override
    public OaUser queryUser(OaUser oaUser) {
        return oaUserMapper.selectByUserName(oaUser);
    }

    @Override
    public void insertNewUser(OaUser oaUser) {
        oaUserMapper.insert(oaUser);
    }

    @Override
    public LoginResult queryUserInfo(OaUser oaUser) {
        return oaUserMapper.selectUserInfo(oaUser);
    }

    @Override
    public PlayerInfoCard queryUserDetail(String name) {
        return playerInfoCardMapper.selectUserInfo(name);
    }

    @Override
    public List<AllPlayerInfoCardInfo> queryAllPlayerInfoCard(Integer pageSize, Integer pageIndex, AllPlayerInfoCardInfo allPlayerInfoCardInfo) {
        Page page = new Page(pageIndex, pageSize);
        return playerInfoCardMapper.selectAllPlayerInfoCard(page, allPlayerInfoCardInfo);
    }

    @Override
    public int queryUserCountByMc(AllPlayerInfoCardInfo allPlayerInfoCardInfo) {
        return playerAccountMapper.selectCount(allPlayerInfoCardInfo);
    }

    @Override
    public String queryUserUuid(String name) {
        return playerInfoCardMapper.selectUserUuid(name);
    }

    @Override
    public int updateUserPwd(String userName, String newPwd) {
        return playerAccountMapper.updateUserPwd(userName, newPwd);
    }

    @Override
    public int updateUserHeadImg(OaUser oaUser) {
        return oaUserMapper.updateByPrimaryKey(oaUser);
    }
}
